package com.ncs.leisure.overall.business.impl;

import java.util.List;
import org.springframework.beans.BeanUtils;
import com.ncs.leisure.overall.business.ContactBusiness;
import com.ncs.leisure.overall.business.dao.MemberDAO;
import com.ncs.leisure.overall.ui.vo.MemberBean;

public class ContactBusinessImpl implements ContactBusiness{

	MemberDAO memberDAO;

	public MemberDAO getMemberDAO() {
		return memberDAO;
	}

	public void setMemberDAO(MemberDAO memberDAO) {
		this.memberDAO = memberDAO;
	}
	
	//用户名密码登录
	
	public Object loginServer(String username,String password){
		
		List<com.ncs.leisure.overall.business.dao.po.Member> memberList=memberDAO.findByUser(username);
		
		if(memberList.size()>1){
			
			return "error:more";
			
		}else if(memberList.size()==0){
			
			return "error:null";			
			
		}else{
			
			com.ncs.leisure.overall.business.dao.po.Member poMember=memberList.get(0);

			if(poMember.getPassword().equals(password)){
				
				MemberBean memberBean=new MemberBean();
				
				BeanUtils.copyProperties(poMember,memberBean);	
		            
				return memberBean;				
				
			}else{
				
				return "error:password";
				
			}
			
			
		}
		
	}
	
}
